package com.huilink.webmail.service.impl;

import com.huilink.db.dbo.AdminMailSettingDbo;
import com.huilink.webmail.dtolayer.AdminMailSetting;

public final class Translator {

	private Translator() {
	}

	public static AdminMailSetting translateAdminMailSetting(
			AdminMailSettingDbo entry) {
		AdminMailSetting adminMailSetting = new AdminMailSetting();
		if (entry != null) {
			adminMailSetting.setFromAddress(entry.getFromAddress());
			adminMailSetting.setFromName(entry.getFromName());
			adminMailSetting.setId(entry.getId());
			adminMailSetting.setSmtpHost(entry.getSmtpHost());
			adminMailSetting.setSmtpPassword(entry.getSmtpPassword());
			adminMailSetting.setSmtpUsername(entry.getSmtpUsername());
			adminMailSetting.setVersion(entry.getVersion());
		}
		return adminMailSetting;
	}

	public static AdminMailSettingDbo translateAdminMailSetting(
			AdminMailSetting entry) {
		if (entry != null) {
			AdminMailSettingDbo settingDbo = new AdminMailSettingDbo(entry
					.getId(), entry.getVersion());
			settingDbo.setFromAddress(entry.getFromAddress());
			settingDbo.setFromName(entry.getFromName());
			settingDbo.setSmtpHost(entry.getSmtpHost());
			settingDbo.setSmtpPassword(entry.getSmtpPassword());
			settingDbo.setSmtpUsername(entry.getSmtpUsername());
			return settingDbo;
		}
		return null;
	}
}
